﻿using System;
using System.Collections;
 
 
 
namespace HttpModuleAccessControl
{

    public class Role  
    {

        ///// <summary>
        ///// Constructor. Not use in this version.
        ///// </summary>
        ///// <param name="Rolename"></param>
        //public Role(string Rolename)
        //{  //load permissions
        
        //}

        ///// <summary>
        ///// Constructor. Not use in this version.
        ///// </summary>
        ///// <param name="RoleID"></param>
        //public Role(int RoleID)
        //{ //load permissions
            
        //}

        /// <summary>
        /// Default Constructor. Do nothing in this version.
        /// </summary>
        public Role()
        { 
            // default constructor and do nothing
        }
 
        private int _RoleID;

        /// <summary>
        /// 
        /// </summary>
        public int RoleID
        {
            get { return _RoleID; }
            set { _RoleID = value; }
        }

        private string _RoleName;

        /// <summary>
        /// 
        /// </summary>
        public string RoleName
        {
            get { return _RoleName; }
            set { _RoleName = value; }
        }

        private int _ParentID;

        /// <summary>
        /// 
        /// </summary>
        public int ParentID
        {
            get { return _ParentID; }
            set { _ParentID = value; }
        }

        // Permissions Collection
        private ArrayList _RolePermissions = new ArrayList();

        /// <summary>
        /// Store Permission ID in a list for this role
        /// </summary>
        public ArrayList PermissionList
        {
            get { return _RolePermissions; }
            set { _RolePermissions = value; }
        }

        #region Not Use in this version

        // Not use in this version.
        //// check if a role owns a permission
        //public bool IsPermissionInRole(int PermissionID)
        //{
        //    bool _answer = false;
        //    if ( _RolePermissions == null)
        //        return false ;

        //    foreach (Permission p in _RolePermissions)
        //    {
        //        if (p.PermissionID == PermissionID)
        //        {
        //            _answer = true;
        //            break;
        //        }
        //    }

        //    return _answer;
        //}

        // Not use in this version.
        //public bool IsPermissionInRole(string PermissionName)
        //{
        //    bool _answer = false;
        //    if (_RolePermissions == null)
        //        return false;

        //    foreach (Permission p in _RolePermissions)
        //    {
        //        if (p.PermissionName.Trim().ToUpper() == PermissionName.Trim().ToUpper())
        //        {
        //            _answer = true;
        //            break;
        //        }
        //    }
        //    return _answer;
        //}

        #endregion

    }

}
